import request from '../utils/request'

//用户注册
export const userRegisterService = (registerData) => {
    //借助于Url.js中的request方法，发送post请求
    const parms = new URLSearchParams();
    for(let key in registerData){
        parms.append(key,registerData[key]);
    }
    return request.post('/admin/register',parms);
}
//用户登录
export const userLoginService = (loginData) => {
    const parms = new URLSearchParams();          
    for(let key in loginData){
        parms.append(key,loginData[key]);
    }
    return request.post('/admin/login',parms);
}
//添加用户
export const addAdminService = (data) => { 
    return request.post('/admin/add', data)
}


//用户信息
export const getUserDataService = () => {
    return request.get('/admin/adminInfo')
}
//所有用户信息
export const getAllUserDataService = () => {
    return request.get('/admin/list')
}
//更新
export const updateUserInfoService = (data) => {
    return request.put('/admin/update', data)
}


export const updatePasswordService = (data) => {
    return request.patch('/admin/updatePwd', data)
}

//删除用户
export const deleteService = (id) => {
    return request.delete('/admin/'+id)
}